﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace FinalDetection
{
  public static class Connect_ADU
    {
        private static int aduHandle;

        /// <summary>
        /// 展示连通ADU列表
        /// </summary>
        public static void ShowList()
        {
            //Displays the available ADU Device(s)
            Module.ADU_DEVICE_ID myAduDeviceId = default(Module.ADU_DEVICE_ID);
            int iRC;
            var argsPrompt = "Connect ADU Devices";
            iRC = Module.ShowAduDeviceList(ref myAduDeviceId, argsPrompt);
        }

        /// <summary>
        /// 计算ADU连通的数量
        /// </summary>
        public static void CountADU()
        {
            //Max 100 ADU device
            //Counts the number of ADU device(s) plugged in
            MessageBox.Show("ADU Count: " + Module.ADUCount(100));
        }

        /// <summary>
        /// 获取ADU属性
        /// </summary>
        public static void GetADU()
        {
            Module.ADU_DEVICE_ID pADU = default(Module.ADU_DEVICE_ID);

            //Displays the ADU device(s) information 
            for (int iAduIndex = 0; iAduIndex <= Module.ADUCount(100) - 1; iAduIndex++)
            {
                Module.GetADU(ref pADU, iAduIndex, 100);
                MessageBox.Show("Index: " + iAduIndex + "   Model: " + pADU.iProductId + "   Serial Number: " + pADU.sSerialNumber);
            }
        }

        /// <summary>
        /// Open s/no Button
        /// </summary>
        /// <param name="num"></param>
        public static void OpenOrClose(string num)
        {
            //Opens the ADU device by its serial number 
           /* var argpSerialNumber = TextBoxOpen.Text;*/
            aduHandle = Module.OpenAduDeviceBySerialNumber(num, 1);
        }
    }
}
